<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!-- 由于网页中name属性的值可以重复，所以getElementByName返回的是数组 -->
<div name="mydiv">div01</div>
<div name="mydiv">div02</div>
<div name="mydiv">div03</div>
<div name="mydiv">div04</div>
<div name="mydiv">div05</div>
<div name="mydiv">div06</div>
<div name="mydiv">div07</div>
</body>
</html>
<script type="text/javascript">
    var divForArray=document.getElementsByName('mydiv');
    console.group('getElementByName获取的是数组');
    for (var index=0;index<divForArray.length;index++){
        console.log(divForArray[index]);
    }
    console.groupEnd();
</script>